package com.kqzz.tbxt;

import com.kqzz.common.dynamicDB.register.DynamicDataSourceRegister;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.*;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.spring.annotation.MapperScan;


@EnableAsync//允许异步
@EnableScheduling
@Import(DynamicDataSourceRegister.class)
//切面相关
@EnableAspectJAutoProxy(proxyTargetClass = true)
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@MapperScan({"com.kqzz.common.mapper", "com.kqzz.tbxt.mapper"})
// 排除common中的Swagger2Config配置，使用自己模块中的Swagger2Config
@ComponentScan(basePackages = {"com.kqzz.common", "com.kqzz.tbxt"},
        excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,
                classes = {com.kqzz.common.config.swagger.Swagger2Config.class}))
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class TbApplication {

    @Autowired
    private RestTemplateBuilder builder;

    @Bean
    public RestTemplate restTemplate() {
        return builder.build();
    }

    public static void main(String[] args) {
        SpringApplication.run(TbApplication.class, args);
    }
}
